<template>
  <div class>
    <!-- 表格 -->
    <!-- <el-container> -->
    <div class="add_table_css">
      <el-table :data="tableData" style="width: 100%">
        <el-table-column type="index" label="序号" width="50"></el-table-column>
        <el-table-column prop="name" label="资格名称" width="180"></el-table-column>
        <el-table-column prop="papers" label="资格证号码" width="150"></el-table-column>
        <el-table-column prop="obtainChannel" label="获取资格途径" width="200"></el-table-column>
        <el-table-column prop="level" label="级别" width="220"></el-table-column>
        <el-table-column prop="obtainTime" label="取得时间" width="130"></el-table-column>
        <el-table-column label="操作" width="100">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" size="small " class="btn_css_er">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- </el-container> -->
    <!-- 查看职业资格的弹框 -->
    <el-dialog title="查看职业资格" :visible.sync="dialogFormVisible2" width="40%" center>
      <el-form
        label-width="110px"
        :model="qualifyTable"
        :rules="rules"
        ref="qualifyTable"
        class="demo-ruleForm add_education_css"
      >
        <el-form-item label="专业技术系列" prop="professionSeries">
          <el-input v-model="qualifyTable.professionSeries"></el-input>
        </el-form-item>
        <el-form-item label="资格名称" prop="name">
          <el-input v-model="qualifyTable.name"></el-input>
        </el-form-item>
        <el-form-item label="资格级别" prop="level">
          <el-input v-model="qualifyTable.level"></el-input>
        </el-form-item>
        <el-form-item label="资格专业" prop="major">
          <el-input v-model="qualifyTable.major"></el-input>
        </el-form-item>
        <el-form-item label="资格证号码" prop="papers">
          <el-input v-model="qualifyTable.papers"></el-input>
        </el-form-item>
        <el-form-item label="获取资格途径" prop="obtainChannel">
          <el-select v-model="qualifyTable.obtainChannel">
            <el-option label="自学" value="自学"></el-option>
            <el-option label="报班" value="报班"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="取得时间" prop="obtainTime">
          <!-- <el-date-picker type="date" placeholder="1987-09-23" v-model="qualifyTable.obtainTime"></el-date-picker> -->
          <el-date-picker
            prop="obtainTime"
            v-model="qualifyTable.obtainTime"
            type="date"
            placeholder="选择日期"
            format="yyyy 年 MM 月 dd 日"
            value-format="timestamp"
          ></el-date-picker>
        </el-form-item>
      </el-form>
    </el-dialog>
    <!-- 分页 -->
    <div class="block page_css">
      <el-pagination
        layout="prev, pager, next"
        :total="total"
        :page-size="limit"
        @current-change="change"
        @prev-click="prev"
        @next-click="next"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      page: 1,
      limit: 5,
      total: 0,
      staffId: 5,

      dialogFormVisible: false,
      dialogFormVisible2: false,
      tableData: [],
      qualifyTable: {
        professionSeries: "",
        name: "",
        level: "",
        major: "",
        papers: "",
        obtainChannel: "",
        obtainTime: ""
      },
      rules: {
        professionSeries: [
          { required: true, message: "请输入毕业院校", trigger: "blur" }
        ],
        name: [{ required: true, message: "请输入毕业院校", trigger: "blur" }],
        level: [{ required: true, message: "请输入毕业院校", trigger: "blur" }],
        major: [{ required: true, message: "请输入毕业院校", trigger: "blur" }],
        papers: [
          { required: true, message: "请输入毕业院校", trigger: "blur" }
        ],
        obtainTime: [
          { required: true, message: "请选择入学时间", trigger: "change" }
        ],
        obtainChannel: [
          { required: true, message: "请选择学位", trigger: "change" }
        ]
      }
    };
  },
  methods: {
    /* 页面渲染 */
    getCon() {
      this.$axios({
        url: "/qualifications/list",
        params: {
          page: this.page,
          limit: this.limit,
          staffId: this.staffId
        }
      }).then(res => {
        // console.log(res.data.data);
        this.tableData = res.data.data;
        this.total = res.data.count;
      });
    },
    /* 分页渲染 */
    change(page) {
      this.page = page;
      this.getCon();
    },
    prev() {
      this.page--;
      this.getCon();
    },
    next() {
      this.page++;
      this.getCon();
    },
    
    handleClick(row) {
      console.log(row);
      this.dialogFormVisible2 = true;
    },
  },
  mounted(){
    this.getCon();
  }
};
</script>
<style scoped lang="less">
.page_css {
  margin: 10px;
  text-align: right;
  margin-right: 135px;
}
.el-table {
  font-size: 13px;
}
.add_table_css {
  border: 1px solid #eee;
  // height: 790px;
  padding: 20px;
  margin-right: 135px;
}
.btn_css_er {
  background-color: #f7f7f7;
  border: 1px solid #eee;
  width: 60px;
  height: 30px;
  text-align: center;
}
.add_education_css {
  width: 300px;
  margin: 0 auto;
  .el-date-picker {
    width: 100px !important;
  }
}
.add_footer_btn_css {
  margin: 0 auto;
}
</style>